package com.whmall.service.crm.algorithm;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * 化合物算法
 * <br/>本地简单版本，专业版本请参考chemical-api
 */
@Component
public class ChemicalAlgorithm {

    @Autowired
    private RedisTemplate<String, Long> longRedisTemplate;

    /**
     * 根据cas获取化合物ID
     * @param cas
     * @return 化合物ID
     */
    public Long getChemicalIdByCas(String cas) {
        return StringUtils.hasText(cas) ?
                (Long) longRedisTemplate.opsForHash().get("@chemical@cas", cas) : null;
    }

}
